/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

*/

#ifndef SCENE_SUBSCENE_H
#define SCENE_SUBSCENE_H

#include "cgpanel/floatmatrix.h"
#include "objects/vertex.h"

using namespace object;

#include <QVector>

namespace scene {

enum OPERATION_TYPE {TRANSLATE = 1, ROTATE, SCALE};
  
class SubScene
{
  public:
    SubScene(){m_transformation = NULL;}
    SubScene(OPERATION_TYPE type, SubScene* parent = NULL)
    {
      m_recursive = true;
      m_type = type;
      m_parent = parent;
    }
    virtual ~SubScene();
    
    inline int getSize(){return m_subScenes.size();}
    inline void addSubScene(SubScene *val){m_subScenes.push_back(val);}
    inline SubScene * getSubScene(int id){return m_subScenes[id];}
    
    inline bool isRecursive(){return m_recursive;}
    inline SubScene *getParent(){return m_parent;}
    
    virtual void setTransFormation(Vertex * temp, float rotate = 0);
    virtual void setTransFormation(draw::FloatMatrix * val){;};
    virtual inline draw::FloatMatrix * getTransformation(){ return
m_transformation;}
    
  private:
    // transformation functions
    void setupTranslation(Vertex * temp);
    void setupRotation(Vertex * temp, float rotate);
    void setupScaling(Vertex * temp);
    
  protected:
    bool m_recursive;
    
  private:
    QVector<SubScene*> m_subScenes;
    OPERATION_TYPE m_type;
    SubScene * m_parent;
    draw::FloatMatrix * m_transformation;
};

}

#endif // SCENE_SUBSCENE_H
